home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TSPA3260.ZIP / TSUNTENV.INT < prev    next >
Text File  |  1992-08-20  |  3KB  |  84 lines

  1. (*
  2. Timo Salmi UNiT ENV
  3. A Turbo Pascal unit of file environment handling routines
  4. All rights reserved 8-Feb-92, 13-Jun-92, 20-Aug-92
  5.  
  6. This unit may be used and distributed freely for PRIVATE, NON-COMMERCIAL,
  7. NON-INSTITUTIONAL purposes, provided it is not changed in any way. For
  8. ANY other usage, such as use in a business enterprise or a university,
  9. contact the author for the terms of registration.
  10.  
  11. The units are under development. Comments and contacts are solicited. If
  12. you have any questions, please do not hesitate to use electronic mail for
  13. communication.
  14. InterNet address: ts@uwasa.fi           (preferred)
  15. Bitnet address:   SALMI@FINFUN.BITNET
  16.  
  17. The author shall not be liable to the user for any direct, indirect or
  18. consequential loss arising from the use of, or inability to use, any unit,
  19. program or file howsoever caused. No warranty is given that the units and
  20. programs will work under all circumstances.
  21.  
  22. Timo Salmi
  23. Professor of Accounting and Business Finance
  24. Faculty of Accounting & Industrial Management; University of Vaasa
  25. P.O. BOX 297, SF-65101 Vaasa, Finland
  26.  
  27. Added 13-Jun-92
  28.  SETENVSH
  29. *)
  30.  
  31. unit TSUNTENV;
  32.  
  33. (* ======================================================================= *)
  34.                           interface
  35. (* ======================================================================= *)
  36.  
  37. uses Dos;
  38.  
  39. (* Get the size of the parent environment. Draws very heavily on the
  40.    article in the PC Magazine Vol. 11, No. 1, pp. 425-427, but also
  41.    includes some programming of my own *)
  42. function ENVSIZFN : word;
  43.  
  44. (* Get the size of the parent environment that is already used up.
  45.    This part of the environment code is primarily due to yours
  46.    truly, and is based on the format of the environment table which
  47.    is name=value1<nul>name=value2<nul>...name=valueN<nul><nul> *)
  48. function ENVUSEFN : word;
  49.  
  50. (* Get the starting segment address of the parent environment. Draws very
  51.    heavily on the article in the PC Magazine Vol. 11, No. 1, p. 425-427,
  52.    but also includes some ideas of my own.
  53.    Returns 0 if the address cannot be found *)
  54. function ENVADDFN : word;
  55.  
  56. (* Set the value of an environment variable. Note that the name of
  57.    the environment variable is CASE SENSITIVE. E.g. you can put
  58.    both COMSPEC and comspec in your environment.  (Don't.)
  59.    Use upper case throughout to be on the safe side.
  60.    This part of the environment code is solely my own (un)doing.
  61.    Status values:
  62.     0 = No errors detected
  63.     1 = Syntax error (Correct syntax: VARIABLE=VALUE)
  64.     2 = Out of environment space
  65.     3 = Missed the variable or the environment
  66.    Note that this takes effect only after the program has terminated!
  67.    Also note that any trailing white spaces are included:
  68.    'VARIABLE=VALUE' and 'VARIABLE=VALUE ' are not the same thing.
  69. *)
  70. procedure SETENV (EnvVar : string; var status : byte);
  71.  
  72. (* Write the parent environment table on stdout *)
  73. procedure SHOWENV;
  74.  
  75. (* Set a temporary value for an environment variable.
  76.    SETENVSH should take effect for the duration of shelling to dos.
  77.    This was a complicated task with parts of code scraped from
  78.    here and there so be a bit wary.
  79.    Everything is made upper case.
  80.    Note the slightly differing syntax from SETENV.
  81. *)
  82. procedure SETENVSH (envvar, envval : string);
  83.  
  84.